Rvest package. You can find more information about the package here
# installing package
install.packages("rvest", quiet = TRUE)
# attaching package
library(rvest, warn.conflicts = FALSE, quietly = TRUE)
https://en.wikipedia.org/wiki/YouTube Browser and find the Xpath that corresponds to the whole table on the right side of the screen.
TablePath <- "/html/body/div[3]/div[3]/div[4]/div/table[1]"
read_html(), html_nodes() and html_table() functions. You can read more about them in the Help panel in R studio or by calling them preceded by two question marks, e.g. ??read_html().
# Setting URL
url <- "https://en.wikipedia.org/wiki/YouTube"
# Reading HTML from URL
html <- read_html(url)
# Navigating to the HTML node with the table object
Node <- html_nodes(html, xpath = TablePath)
# Extracting the table to R-object
Table <- html_table(Node)
# unlisting dataframe
YouTubeData <- Table[[1]]